package model

import (
	"github.com/Unixeno/TheMoon/common/zone"
	"time"
)

type ZoneState int

const (
	ZoneCreated ZoneState = iota
	ZoneSynced
	ZoneDeploying
)

type Zone struct {
	ID        string     `gorm:"size:40;primary_key:true"` // ZoneID
	Name      string     `gorm:"size:40;unique_index"`     // zone名称
	Version   int        `gorm:"default:0;not null"`       // zonefile版本号
	Zonefiles []Zonefile `gorm:"foreignkey:ZoneID;PRELOAD:false"`
	// zone内的节点
	Moons []Moon `gorm:"many2many:zone_moons;"`

	State     ZoneState // Zone状态
	CreatedAt time.Time
}

type ZoneMoon struct {
	ZoneID  string             `gorm:"size:40;primary_key"`
	MoonID  string             `gorm:"size:40;primary_key"`
	Version int                `gorm:"default:0;not null"`
	State   zone.ZoneMoonState `gorm:"default:0;not null"`
}
